<?php
	DEFINE('H1', 'File Uploader');
	DEFINE('TITLE','File Uploader');
	require('includes/header.php');
?>	
	<h2><?PHP echo H1 ?></h2>

<?php

	if(!isset($_POST['submit'])) {
?>

<form enctype="multipart/form-data" method="post" action="fileupload.php">
	<input type="file" name="survey" /><br /><br />
	<input type="submit" name="submit" value="Upload Files" />
</form>

<?php
	} else {
		foreach($_FILES as $f=>$k) {
			wrt("$f is $k");
			foreach($k as $fl=>$kl)
				wrt("$fl holds $kl");
	}
	
	$myFile = "misc/" . $_FILES['survey']['name'];
	
	echo "Checking for uploaded file $myFile... <br />\n";
	
	if(move_uploaded_file($_FILES['survey']['tmp_name'], $myFile))
		wrt("Upload successful.");
	else
		wrt("Upload failed.");
	}
?>

<?php
	require('includes/footer.php');
?>